package com.wolf.cx330.data_binding

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.wolf.cx330.R
import com.wolf.cx330.databinding.ActivityDataBindingBinding

/**
 * databinding 只需要早gradle文件android中加入
 * dataBinding {
 *  enabled = true
 * }
 */
class DataBindingAct : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val binding: ActivityDataBindingBinding = DataBindingUtil.setContentView(this, R.layout.activity_data_binding)
        binding.user = User("RedWolfChao", "git1234566678")
//        binding.userList = listOf(
//            User("RedWolfCha1", "git1111111"),
//            User("RedWolfCha2", "git22222222"),
//            User("RedWolfCha3", "git3333333"),
//            User("RedWolfCha4", "git4444444"))
//        binding.userMap = mapOf(
//            "RedWolfCha1" to "git1111111",
//            "RedWolfCha22" to "git1112222",
//            "RedWolfCha33" to "git3333333",
//            "RedWolfCha545" to "git5555555")
        binding.index = 2
        binding.key = "RedWolfCha22"

    }

    companion object {
        fun actionStart(context: Context) {
            context.startActivity(Intent(context, DataBindingAct::class.java))
        }
    }
}